package main

import (
	"context"
	"embed"
	"github.com/wailsapp/wails/v2"
	"github.com/wailsapp/wails/v2/pkg/options"
	"github.com/wailsapp/wails/v2/pkg/options/assetserver"
	"github.com/wailsapp/wails/v2/pkg/options/mac"
	app_menu "wail/app/menu"
	"wail/app/pkg"
)

//go:embed all:frontend/dist
var assets embed.FS

func main() {
	// Create an instance of the app structure
	//实例化用户对象
	user := pkg.NewApp()
	app := app_menu.NewApp()
	// Create application with options
	err := wails.Run(&options.App{
		//title
		Title: "lsr",
		// 屏幕宽度
		Width: 1024,
		//屏幕高度
		Height: 768,
		//禁用调整窗口尺寸
		DisableResize: true,
		//默认设置静态文件
		AssetServer: &assetserver.Options{
			Assets: assets,
		},
		//设置背景颜色
		BackgroundColour: &options.RGBA{R: 27, G: 38, B: 54, A: 1},
		//设置启动 context
		OnStartup: func(ctx context.Context) {
			app.Startup(ctx)
		},
		//设置menu
		Menu: app.Menu(),
		//关于mac设备的特殊选项
		Mac: &mac.Options{
			TitleBar: mac.TitleBarHidden(), //设置title bar隐藏
		},
		//绑定方法
		Bind: []interface{}{
			app,
			user,
		},
	})

	//设置menu
	if err != nil {
		println("Error:", err.Error())
	}
}
